<?php
include 'islogin.php';
include '../config.php';

if(isset($_GET['flag']))
{

	if($_GET['flag']=='update')
	{
		$id = $_GET["id"];
		$sql = "select a.id,a.name,a.url,a.remark,a.counts,a.description,a.dates,a.size,a.type_,a.pro_id,b.name as type_name from download as a inner join download_type as b on a.type_=b.id  where a.flag =1 and a.id=".$id;
		$result = mysql_query($sql);
		$row = mysql_fetch_array($result);
		
	}
}
if(isset($_POST['flag']))
{
	if($_POST['flag']=='update')
	{
		$sql = "update download set name='".$_POST["name"]."',url='".$_POST["url"]."',size='".$_POST["size"]."',type_=".$_POST["type_"].",remark='".$_POST["remark"]."',counts=".$_POST["counts"].",description='".$_POST['description']."' where id=".$_POST["id"];
		mysql_query($sql);
		echo "<script>window.location.href='downloadAdd.php?id=".$_POST["pro_id"]."'</script>";
		
	}
}
?>
<script src="../js/jquery-1.7.1.js"></script>
<link href="images/skin.css" rel="stylesheet" type="text/css" />
<link href="css/right.css" rel="stylesheet" type="text/css"/>
<link href="js/upload/uploadify.css" rel="stylesheet" type="text/css" />
<script src="js/upload/swfobject.js"></script>
<script src="js/upload/jquery.uploadify.v2.1.4.min.js"></script>
<style>
   #img_uploadUploader{vertical-align:middle}
</style>
<script>
$(document).ready(function(){

	   $('#img_upload').uploadify({
		   'uploader':'js/upload/uploadify.swf',
		   'cancelImg':'js/upload/cancel.png',
		   'fileExt':'*.png',
		   'script':'file_upload.php',
		   'auto':true,
		   'folder':'upload',
		   'buttonImg':'images/Browse.png',
		   'width':70,
		   'height':25,
		   'wmode':'transparent',
		   'onComplete':function(event,queueId,fileObj,response,data){
			   	 
			     $("#url").val(fileObj.filePath);
			     $("#size").val(fileObj.size);
			   }
	});
});
</script>


<div style="border:0px solid red;"> 

    	<div id="top"><div>相关下载</div></div>
    	<div id="middle">
    	
    		
    	</div>
    	<div id="bottom"></div>	
    	<div class="layout">
		  		<div class="title">下载修改</div>
		  		<div class="content">
		  			<form action="downloadUpdate.php" method="post">
		  			 <input type="hidden" name="flag" value="update" />
			         <input type="hidden" name="id" value="<?php echo $row["id"];?>" />
			         <input type="hidden" name="pro_id" value="<?php echo $row["pro_id"];?>" />
			  			<table  cellspacing="0" cellpadding="0">  
				          	<tr>
				          		<td class="title_some_td" style="width:100px;">名称:</td>
				          		<td><input name="name" value="<?php echo $row["name"];?>"  /></td>
				          	</tr>
				          	
				          	<tr>
				          		<td class="title_some_td" style="width:100px;">下载文件:</td>
				          		<td  style="width:300px;"><input id="url" name="url" value="<?php echo $row["url"];?>"  /> <input id="img_upload" /></td>
				          	</tr>
				          	
				          	<tr>
				          		<td class="title_some_td" style="width:100px;">文件大小:</td>
				          		<td><input id="size" name="size" value="<?php echo $row["size"];?>"  />byte(字节)</td>
				          	</tr>
				          	<tr>
				          		<td class="title_some_td" style="width:100px;">下载类型:</td>
				          		<td>
				          		<?php $type_id=$row["type_"];?>
				          			<select name="type_">
				          				<?php include 'select_downloadType.php';?>
				          			</select>
				          		</td>
				          	</tr>
				          	<tr>
				          		<td class="title_some_td" style="width:100px;">版本:</td>
				          		<td><input id="remark" name="remark" value="<?php echo $row["remark"];?>"  /></td>
				          	</tr>
				          	<tr>
				          		<td class="title_some_td" style="width:100px;">初始下载次数:</td>
				          		<td><input id="counts" name="counts" value="<?php echo $row["counts"]?>"  /></td>
				          	</tr>
				          	<tr>
                                <td class="title_some_td" style="width:100px;">说明:</td>
                                <td><textarea style="width:200px; height:100px;" name="description"><?php echo $row['description'];?></textarea></td>
                            </tr>
				          	<tr>
			          		<td></td>
			          		<td><input type="submit" value="保存" /></td>
			          	</tr>
				         </table> 
			        </form> 	
		  		</div>
		  </div>
</div>    	